package com.woniu.woniuproject.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.woniuproject.entity.Debtor;
import com.woniu.woniuproject.mapper.DebtorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DebtorService {
    @Autowired
    DebtorMapper debtorMapper;

    public int adddebtor(Debtor debtor) {
        int i = debtorMapper.insert(debtor);
        return i;
    }
        public PageInfo<Debtor> selectApplyList(int currentPage, int pageSize, Date start, Date end){
            PageHelper.startPage(currentPage,pageSize);
            List<Debtor> list = debtorMapper.selectApplyList(start,end);
            PageInfo<Debtor> pageInfo = new PageInfo<>(list);
            return pageInfo;
        }

        public int updateById(int debtorid){
        int i=debtorMapper.updateById(debtorid);
        return i;
        }

    public int updateByunId(int debtorid) {
        int i=debtorMapper.updateByunId(debtorid);
        return i;
    }

    public PageInfo<Debtor> selectByStatus(int currentPage, int pageSize) {
        PageHelper.startPage(currentPage,pageSize);
        List<Debtor> list = debtorMapper.selectByStatus(1);
        PageInfo<Debtor> pageInfo = new PageInfo<>(list);
        return pageInfo;

    }

    public Debtor selectById(int debtorid) {
        Debtor debtor = debtorMapper.selectByPrimaryKey(debtorid);
        return debtor;
    }
}
